import Vue from 'vue';
import Router from 'vue-router';
//定懒加载方式的路由
const Login   = resolve => require(['@/components/auth/login.vue'], resolve);//登录
const Base    = resolve => require(['@/components/layout/base.vue'], resolve);//共有布局
//主页
const Main    = resolve => require(['@/components/index/index.vue'], resolve);//公众登录
//用户
const User    = resolve => require(['@/components/user/index.vue'], resolve);//用户管理

const Error404= resolve => require(['@/components/page/404.vue'], resolve);//404

Vue.use(Router);
export const constantRouterMap= [
    {path: '/', name: 'Login', component: Login, meta: {title: '登录', login:true}},
    {
        path: '/',
        component: Base,
        children:[
            {
                path: '/error/404',
                meta: {title:'404',show:false},
                component: Error404,
            },
        ],
    }
];
//异步挂载的路由
export const asyncRouterMap = [
    {
        path: '/',
        component: Base,
        children:[
            {
                path: '/main',
                name: 'Main',
                meta: {title:'活动管理',show:true,'icon':'fa fa-home'},
                component: Main,
            },
            {
                path: '/user',
                name: 'User',
                meta: {title:'用户管理',show:true,'icon':'fa fa-user'},
                component: User,
            },
        ],
    },
    { path: '*',name:'404', redirect: '/error/404',meta: {show:false}, }
]
//实例化vue的时候只挂载constantRouter
export default new Router({
    mode: 'history',
    routes: constantRouterMap
});